package com.tzb.shirospringbootjsp.utils;


import java.util.Random;

/**
 * @Description TODO
 * @Author tzb
 * @Date 2021/8/29 0:10
 * @Version 1.0
 **/
public class SaltUtils {

    /**
     * @param n
     * @return
     */
    public static String getSalt(int n) {

        char[] chars = "ABCDEFGHIGKLMNOPQRSTUVWXYZabcdefghigklmnopqrstuvwxyz0123456789!@#$%^&*()".toCharArray();

        StringBuilder sb = new StringBuilder();

        for (int i = 0; i < n; i++) {
            char aChar = chars[new Random().nextInt(chars.length)];
            sb.append(aChar);
        }
        return sb.toString();
    }

    public static void main(String[] args) {
        System.out.println(getSalt(5));
    }
}
